/**
 * Created by 86185 in 2020/8/16 on 13:50
 */
const fs = require("fs");
const path = require("path");

class ConfigUtil {
    constructor() {
        this.config = this.queryConfigFromFile();
    }

    queryConfigFromFile() {

        let configFile = path.join(process.cwd(), "middleware/config.json");

        let fileRes = fs.readFileSync(configFile, "utf-8");

        let config = JSON.parse(fileRes);

        config.print = (logger) => {
            logger.info(`读取配置文件：${configFile}`);
            logger.info(`config：${fileRes}`);
        };

        return config;
    }

    getConfig() {
        return this.config;
    }
}

export default new ConfigUtil().getConfig()
